using System;
using System.Collections.Generic;
using Text = System.Text;

using ESBSimpleSamples.ServiceComponents.Interfaces;

namespace ESBSimpleSamples.ServiceComponents.Encoding
{
    public abstract class EncodingServiceBase : IEncodingService
    {
        protected abstract Text.Encoding Encoding
        {
            get;
        }

        #region IEncodingService Members

        public string GetCharacter(byte[] characterCode)
        {
            string character = this.Encoding.GetString(characterCode);
            return character;
        }

        public byte[] GetCharacterCode(string character)
        {
            byte[] characterCode = null;
            if (!string.IsNullOrEmpty(character) && character.Length == 1)
            {
                characterCode = this.Encoding.GetBytes(character);
            }
            return characterCode;
        }

        #endregion
    }
}
